package com.mobile;
import com.mobile.util.DateUtil;
import com.mobile.util.PageData;

import java.io.*;
import java.util.*;


public class TestClass {
    public static int mount = 0;
    public static void main(String[] args)
    {
        String i = "111";
        System.out.println(i.hashCode());
    }
    public static boolean isTrueFile(File file)
    {
        if(!file.exists() || !file.canRead())
            return false;
        if (file.getName().startsWith("."))
            return false;
        if (file.getName().endsWith("."))
            return false;
        return true;
    }
    public static List<PageData> findFile(String filePath, String word)
    {

        File file = new File(filePath);
        List<PageData> fileList = new ArrayList<>();
        File[] listFiles = file.listFiles();
        //得到一个File数组，它默认是按文件最后修改日期排序的
        for (int i = 0; i < listFiles.length; i++)
        {
            if (isTrueFile(listFiles[i])) {
                String fileName = listFiles[i].getName();
                if (fileName.contains(word)) {
                    PageData fileData = new PageData();
                    String date = DateUtil.date2Str(new Date(listFiles[i].lastModified()));
                    fileData.put("fileName", fileName);
                    fileData.put("updateTime", date);
                    fileList.add(fileData);
                }
            }

        }
        return fileList;
    }

}
